package com.micro.ai.gateway.config;

import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Timer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 监控配置
 * 
 * @author micro-ai
 * @since 0.0.1
 */
@Configuration
public class MonitorConfig {

    /**
     * 请求计数器
     */
    @Bean
    public Counter requestCounter(MeterRegistry meterRegistry) {
        return Counter.builder("gateway.requests.total")
                .description("网关总请求数")
                .register(meterRegistry);
    }

    /**
     * 错误计数器
     */
    @Bean
    public Counter errorCounter(MeterRegistry meterRegistry) {
        return Counter.builder("gateway.errors.total")
                .description("网关错误数")
                .register(meterRegistry);
    }

    /**
     * 限流计数器
     */
    @Bean
    public Counter rateLimitCounter(MeterRegistry meterRegistry) {
        return Counter.builder("gateway.rate_limit.total")
                .description("限流次数")
                .register(meterRegistry);
    }

    /**
     * 响应时间计时器
     */
    @Bean
    public Timer responseTimer(MeterRegistry meterRegistry) {
        return Timer.builder("gateway.response.time")
                .description("网关响应时间")
                .register(meterRegistry);
    }
}
